//
//  ForgetPassView.m
//  fitnessmanage
//
//  Created by 众拳科技 on 2017/10/17.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "ForgetPassView.h"

@implementation ForgetPassView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = CSWhiteColor;
        
        NSMutableDictionary *attrs = [NSMutableDictionary dictionary];// 创建属性字典
        attrs[NSFontAttributeName] = MidBigFont; // 设置font
        attrs[NSForegroundColorAttributeName] = PlaceHoldColor; // 设置颜色
        
        /**
         忘记密码
         */
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.text = @"忘记密码";
        titleLabel.font = BoldBigFont;
        titleLabel.textColor = CSColorFromRGB(0x0a0a0a);
        [self addSubview:titleLabel];
        self.titleLabel = titleLabel;
        
        /**
         手机TF
         */
        UITextField *accountTF = [[UITextField alloc] init];
        //        phoneTF.backgroundColor = CSRedColor;
        accountTF.clearButtonMode=UITextFieldViewModeWhileEditing;
        accountTF.keyboardType = UIKeyboardTypeNumberPad;
        accountTF.font = MidBigFont;
        accountTF.textColor = CSColorFromRGB(0x212121);
        NSAttributedString *accountAttStr = [[NSAttributedString alloc] initWithString:@"请输入您的账号" attributes:attrs]; // 初始化富文本占位字符串
        accountTF.attributedPlaceholder = accountAttStr;
        [self addSubview:accountTF];
        self.accountTF = accountTF;
        
        UIView *accountLineView = [[UIView alloc] init];
        accountLineView.backgroundColor = LineBackGroundColor;
        [self addSubview:accountLineView];
        self.accountLineView = accountLineView;
        
        /**
         +86
         */
        UILabel *phoneFrontLabel = [[UILabel alloc] init];
        phoneFrontLabel.text = @"+86";
        phoneFrontLabel.font = MidBigFont;
        phoneFrontLabel.textColor = CSColorFromRGB(0x0a0a0a);
        [self addSubview:phoneFrontLabel];
        self.phoneFrontLabel = phoneFrontLabel;
        
        UIImageView *downImageView = [[UIImageView alloc] init];
        downImageView.image = [UIImage imageNamed:@"down"];
        [self addSubview:downImageView];
        self.downImageView = downImageView;
        
        /**
         手机TF
         */
        UITextField *phoneTF = [[UITextField alloc] init];
        //        phoneTF.backgroundColor = CSRedColor;
        phoneTF.clearButtonMode=UITextFieldViewModeWhileEditing;
        phoneTF.keyboardType = UIKeyboardTypeNumberPad;
        phoneTF.font = MidBigFont;
        NSAttributedString *phoneAttStr = [[NSAttributedString alloc] initWithString:@"请输入您的手机号" attributes:attrs]; // 初始化富文本占位字符串
        phoneTF.attributedPlaceholder = phoneAttStr;
        phoneTF.textColor = CSColorFromRGB(0x212121);
        [self addSubview:phoneTF];
        self.phoneTF = phoneTF;
        
        UIView *phoneLineView = [[UIView alloc] init];
        phoneLineView.backgroundColor = LineBackGroundColor;
        [self addSubview:phoneLineView];
        self.phoneLineView = phoneLineView;
        
        /**
         验证码TF
         */
        UITextField *vercodeTF = [[UITextField alloc] init];
        vercodeTF.font = MidBigFont;
        vercodeTF.textColor = CSColorFromRGB(0x212121);
        NSAttributedString *vercodeAttStr = [[NSAttributedString alloc] initWithString:@"请输入验证码" attributes:attrs]; // 初始化富文本占位字符串
        vercodeTF.attributedPlaceholder = vercodeAttStr;
        vercodeTF.keyboardType = UIKeyboardTypeNumberPad;
        [self addSubview:vercodeTF];
        self.vercodeTF = vercodeTF;
        
        /**
         发送验证码
         */
        UIButton *sendVercodeBtn = [[UIButton alloc] init];
        [sendVercodeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
        sendVercodeBtn.titleLabel.font = MidBigFont;
        [sendVercodeBtn setTitleColor:CSColorFromRGB(0x0a0a0a)forState:UIControlStateNormal];
        [self addSubview:sendVercodeBtn];
        self.sendVercodeBtn = sendVercodeBtn;
        
        UIView *phoneineView1 = [[UIView alloc] init];
        phoneineView1.backgroundColor = LineBackGroundColor;
        [self addSubview:phoneineView1];
        self.phoneineView1 = phoneineView1;
        
        /**
         下一步按钮
         */
        UIButton *nextBtn = [[UIButton alloc] init];
        nextBtn.backgroundColor = ButtonBackGroundColor;
        nextBtn.layer.cornerRadius = 4;
        nextBtn.layer.masksToBounds = YES;
        [nextBtn setTitle:@"下一步"forState:UIControlStateNormal];
        [nextBtn setTitleColor:CSBlackColor forState:UIControlStateNormal];
        nextBtn.titleLabel.font = BigFont;
        [self addSubview:nextBtn];
        self.nextBtn = nextBtn;
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{
    
    
    /**
     设置登录密码
     */
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self).offset(15);
        
        make.left.mas_equalTo(self).offset(25);
        
        make.height.mas_equalTo(60);
    }];
    
    /**
     手机TF
     */
    [self.accountTF mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(20);
        
        make.left.mas_equalTo(self).offset(25);
        
        make.right.mas_equalTo(self).offset(-25);
        
        make.height.mas_equalTo(40);
    }];
    
    [self.accountLineView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.width.mas_equalTo(self.accountTF);
        
        make.height.mas_equalTo(1);
        
        make.top.mas_equalTo(self.accountTF.mas_bottom).offset(10);
    }];
    
    /**
     +86
     */
    [self.phoneFrontLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self).offset(25);
        
        make.centerY.mas_equalTo(self.phoneTF);
        
        make.width.mas_equalTo(35);
    }];
    
    [self.downImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.phoneFrontLabel);
        
        make.left.mas_equalTo(self.phoneFrontLabel.mas_right);
        
        make.width.height.mas_equalTo(5);
    }];
    
    /**
     手机TF
     */
    [self.phoneTF mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.accountLineView.mas_bottom).offset(15);
        
        make.left.mas_equalTo(self.downImageView.mas_right).offset(20);
        
        make.right.mas_equalTo(self).offset(-25);
        
        make.height.mas_equalTo(40);
    }];
    
    [self.phoneLineView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.phoneFrontLabel);
        
        make.right.mas_equalTo(self).offset(-25);
        
        make.height.mas_equalTo(1);
        
        make.top.mas_equalTo(self.phoneTF.mas_bottom).offset(10);
    }];
    
    /**
     验证码TF
     */
    [self.vercodeTF mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.phoneLineView.mas_bottom).offset(15);
        
        make.left.mas_equalTo(self).offset(25);
        
        make.right.mas_equalTo(self).offset(-25);
        
        make.height.mas_equalTo(self.phoneTF);
    }];

    /**
     发送验证码
     */
    [self.sendVercodeBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.right.mas_equalTo(self).offset(-15);

        make.width.mas_equalTo(120);

        make.height.mas_equalTo(30);

        make.centerY.mas_equalTo(self.vercodeTF);
    }];

    [self.phoneineView1 mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.left.width.mas_equalTo(self.vercodeTF);

        make.height.mas_equalTo(1);

        make.top.mas_equalTo(self.vercodeTF.mas_bottom).offset(10);

    }];

    //下一步
    [self.nextBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(self.phoneineView1.mas_bottom).offset(35);

        make.left.mas_equalTo(self).offset(30);

        make.right.mas_equalTo(self).offset(-30);

        make.height.mas_equalTo(50);
    }];
}

@end
